﻿package com.porganized.heatmap{
	import flash.display.Bitmap;
    import flash.display.BitmapData;

	public class hBitmapData extends BitmapData {
		//var shooterShip:MovieClip;
		//var thisParent:*;

		public function hBitmapData(width, height, transparent, fillColor) {
			var myBitmapData:BitmapData = new BitmapData(width, height, transparent, fillColor);
			//this.addEventListener(Event.ADDED, initialize);
		}
/*		function initialize(event:Event):void {
			//thisParent =  event.currentTarget.parent;
			//thisBullet = MovieClip(this.parent.getChildByName(this.name));
		}*/
		public function numPixels() {
			return this.width*this.height;
		}
		
		public function pixelAt(percent) {
			 var currentPix = numPixels()*percent/100;
			 var currentPixRow = Math.floor(currentPix/myBitmapData.width);
			 var currentPixColumn = currentPix-currentPixRow*myBitmapData.width;
		 
			trace (numPixels(), currentPix, currentPixRow, currentPixColumn);
			myBitmapData.setPixel(currentPixColumn, currentPixRow, 0xFF0000);
			myBitmapData.setPixel(currentPixColumn+1, currentPixRow, 0xCC0000);
			myBitmapData.setPixel(currentPixColumn-1, currentPixRow, 0xCC0000);
			myBitmapData.setPixel(currentPixColumn, currentPixRow+1, 0xCC0000);
			myBitmapData.setPixel(currentPixColumn, currentPixRow-1, 0xCC0000);
			
			myBitmapData.setPixel(currentPixColumn+2, currentPixRow, 0x770000);
			myBitmapData.setPixel(currentPixColumn-2, currentPixRow, 0x770000);
			myBitmapData.setPixel(currentPixColumn, currentPixRow+2, 0x770000);
			myBitmapData.setPixel(currentPixColumn, currentPixRow-2, 0x770000);
			myBitmapData.setPixel(currentPixColumn+1, currentPixRow+1, 0x770000);
			myBitmapData.setPixel(currentPixColumn-1, currentPixRow+1, 0x770000);
			myBitmapData.setPixel(currentPixColumn+1, currentPixRow-1, 0x770000);
			myBitmapData.setPixel(currentPixColumn-1, currentPixRow-1, 0x770000);
		}
		
		
		
	}
}

/*

var myBitmapData:BitmapData = new BitmapData(40, 80, false, 0x000000);

var pixelValue:uint = myBitmapData.getPixel(50, 50);
trace(pixelValue.toString(16));



for (var i:uint = 0; i < 6; i++)
{
pixelAt (i*(100/6));
}
var myBitmapImage:Bitmap = new Bitmap(myBitmapData);
addChild(myBitmapImage);
myBitmapImage.width = 200;
myBitmapImage.height = 400;




*/